<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>宇成建筑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../statics/css/font.css">
    <link rel="stylesheet" href="../statics/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="../statics/css/xadmin.css">
    <link rel="stylesheet" href="../statics/css/style.css">
    <style>
        .layui-colla-icon {
            left: 96% !important;
        }
    </style>
</head>

<body class='labelAuto'>
<div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="welcome.html">首页</a>
            <a href="javascript:;">仓库管理</a>
            <a href="javascript:;">仓库物资<span class="projectName"></span></a>
            <a href="javascript:;">采购单</a>
            <a>
                <cite>收货记录</cite>
            </a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right:10px"
       onclick="window.history.go(-1)" title="后退">
        <i class="iconfontBlod" style="line-height:30px">&#xe74f;</i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-d layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body search">
                    <form action="" class="layui-form livingList">
                        <div class="layui-item">
                        </div>
                    </form>
                </div>
                <div class="layui-card-body tableCardBody">
                    <table class="layui-table" id="lists" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="../statics/plugins/layui/layui.js" charset="utf-8"></script>
<script src='../statics/plugins/jQuery-3.2.1/jquery-3.2.1.min.js'></script>
<script type="text/javascript" src="../statics/plugins/X-admin/xadmin.js"></script>
<script type="text/javascript" src="../statics/js/public.js?v=1129"></script>
<script type="text/javascript">
    layui.use(['form', 'layer', "table"], function () {
        $('span.projectName').html(`(${localStorage.getItem('projectName')})`);
        var orderId = Number(getQueryString('orderId'));
        var data = '';
        // 异步数据加载
        $.ajax({
            url: url + "/finance/supplier/orderReceived",
            type: "POST",
            async:false,
            data: {
                orderId: Number(orderId),
                token: getToken()
            },
            success: function (r) {
                if (r.code == 100000) {
                    data = r.data;
                } else {
                    tips('收货记录', r);
                }
            }
        })
        var th = ``;

        var tr = '';
        for(var j=0;j<data.length;j++){
            tr +=`<tr><td>${data[j].materialName}(${data[j].spec})</td>`
            for (var k=0;k<data[j].info.length;k++){
                if (j===0){
                    if (k===0){
                        th += `<th>订货数量</th>`
                    }else{
                        th += `<th>第${k}次收货(${data[j].info[k].receivingTime.substr(0,10)})</th>`
                    }
                }
                tr += `<td>${data[j].info[k].amount}</td>`
            }
            tr+= `</tr>`
        }
        var thead = `<thead><tr><th></th>${th}</tr></thead>`;
        var tbody = `<tbody>${tr}</tbody>`
        $('table').html(thead+tbody)
    });
</script>
</html>